package cn.iocoder.yudao.module.exam.dal.mysql.questions;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.exam.dal.dataobject.questions.QuestionsDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.exam.controller.admin.questions.vo.*;

/**
 * 考试题库 Mapper
 *
 * @author Francis
 */
@Mapper
public interface QuestionsMapper extends BaseMapperX<QuestionsDO> {

    default PageResult<QuestionsDO> selectPage(QuestionsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<QuestionsDO>()
                .eqIfPresent(QuestionsDO::getGrade, reqVO.getGrade())
                .eqIfPresent(QuestionsDO::getSubject, reqVO.getSubject())
                .eqIfPresent(QuestionsDO::getSource, reqVO.getSource())
                .eqIfPresent(QuestionsDO::getQuestionType, reqVO.getQuestionType())
                .eqIfPresent(QuestionsDO::getQuestionContent, reqVO.getQuestionContent())
                .eqIfPresent(QuestionsDO::getStandardAnswer, reqVO.getStandardAnswer())
                .eqIfPresent(QuestionsDO::getAnswerAnalysis, reqVO.getAnswerAnalysis())
                .eqIfPresent(QuestionsDO::getScoringCriteria, reqVO.getScoringCriteria())
                .likeIfPresent(QuestionsDO::getKnowledgePoints, reqVO.getKnowledgePoints())
                .eqIfPresent(QuestionsDO::getDifficultyLevel, reqVO.getDifficultyLevel())
                .orderByDesc(QuestionsDO::getId));
    }

}